﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using NUnit.Framework;
using Pantry.Entity;
using Pantry.Business;
using Pantry.Commons;
using Pantry.DataAccess;

namespace Pantry.UnitTest
{
    /// <summary>
    /// HaiNHH1
    /// Test toan bo nghiep vu ve TrustRegion
    /// </summary>
    [TestFixture]
    public class TestTrustRegion
    {
        private TransactionScope _transactionScope;
        private TrustRegionBus _trustRegionBus;
        private TrustRegion _trustRegion;
        private const string ConnectionString = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
        /// <summary>
        /// Khoi tao cac hoat dong chuan bi test.
        /// </summary>
        [SetUp]
        public void Init()
        {
            _transactionScope = new TransactionScope();
            _trustRegionBus = new TrustRegionBus(ConnectionString);
        }
        /// <summary>
        /// Tears down.
        /// </summary>
        [TearDown]
        public void TearDown()
        {
            _transactionScope.Dispose();
            _trustRegionBus.Dispose();
        }
        //Test phuong thuc add du lieu.
        /// <summary>
        /// Tests the add trust region_ input valid trust region object_ return true.
        /// </summary>
        [Test]
        public void TestAddTrustRegion_InputValidTrustRegionObject_ReturnTrue()
        {
            _trustRegion = new TrustRegion
                               {
                                   TrustRegionId = 1,
                                   TrustRegionName = "Trust Region 123",
                                   Description = "Trust region 12345",
                                   CountryId = 1,
                                   CountryName = "Australia",
                                   IsActive = true
                               };
            var actual = _trustRegionBus.CreateTrustRegion(_trustRegion);
            Assert.AreEqual(true, actual);
        }
        [Test]
        public void TestAddTrustRegion_InputTrustRegion_NameIsExists_ReturnFalse()
        {
            _trustRegion = new TrustRegion()
                               {
                                   TrustRegionId = 1,
                                   TrustRegionName = "Vietnam north",
                                   Description = "Vietnam North",
                                   CountryId = 1,
                                   CountryName = "Australia",
                                   IsActive = true
                               };
            bool actual = false;
            if (!_trustRegionBus.CheckTrustRegionIsExists(_trustRegion.TrustRegionName))
            {
                actual = _trustRegionBus.CreateTrustRegion(_trustRegion);
            }
            Assert.AreEqual(false, actual);
        }
        [Test]
        public void TestAddTrustRegion_InputTrustRegion_NameIsNull_ReturnFalse()
        {
            _trustRegion = new TrustRegion()
            {
                TrustRegionId = 1,
                Description = "Vietnam North",
                CountryId = 1,
                CountryName = "Australia",
                IsActive = true
            };
            var actual = _trustRegionBus.CreateTrustRegion(_trustRegion);
            Assert.AreEqual(false, actual);
        }
        [Test]
        public void TestAddTrustRegion_InputNullTrustRegion_ReturnFalse()
        {
            var actual = _trustRegionBus.CreateTrustRegion(_trustRegion);
            Assert.AreEqual(false, actual);
        }
        [Test]
        public void TestAddTrustRegion_InputTrustRegion_PropertiesNull_ReturnFalse()
        {
            _trustRegion = new TrustRegion();
            var actual = _trustRegionBus.CreateTrustRegion(_trustRegion);
            Assert.AreEqual(false, actual);
        }
        //Test Phuong thuc update du lieu
        [Test]
        public void TestUpdateRegion_InputValidTrustRegionObject_ReturnTrue()
        {
            
        }
    }
}
